<template>
  <div class="app-container">
    ssss
    <ReportForm :model-name="modelName" @changed="getData">
      //
    </ReportForm>

    <div>
      <li v-for="item in data" :key="item.id">
        <div>{{ item.partner_id }} , {{ item.partner_name }}</div>
        <el-table :data="item.tableData" style="width: 100%">
          <el-table-column
            v-for="col in columns"
            :key="col.name"
            :prop="col.name"
            :label="col.label"
          />
        </el-table>
      </li>
    </div>
  </div>
</template>

<script>
// import odoo from '@/odooapi'

import ReportForm from '@/selfComponents/Report/ReportForm'

const modelName = 'report.accounting_pdf_reports.report_partnerledger'

export default {
  name: '',
  components: { ReportForm },
  directives: {},
  filters: {},

  data() {
    return {
      modelName: modelName,
      data: [],
      columns: [
        { name: 'date', label: '日期' },
        { name: 'code', label: '凭证类型' },
        { name: 'a_code', label: '科目代码' },
        { name: 'a_name', label: '科目名称' },
        { name: 'displayed_name', label: '凭证' },
        { name: 'debit', label: '借方' },
        { name: 'credit', label: '贷方' },
        { name: 'progress', label: '余额' }
      ]
    }
  },
  async created() {},
  methods: {
    async getData(res) {
      console.log('xxxxxxx, detail data,', res)
      this.data = res.report_data.map(item => {
        return {
          ...item,
          tableData: [
            {
              date: undefined,
              code: undefined,
              a_code: '合计',
              a_name: undefined,
              displayed_name: undefined,
              debit: item.debit,
              credit: item.credit,
              progress: item.balance
            },
            ...item.lines
          ]
        }
      })

      console.log('xxxxxxx, detail data,', this.data)

      // this.data = res.report_data
    }
  }
}
</script>
